let fs = require('fs');
let userData = fs.readFileSync(__dirname + '/persons.json', 'utf-8');
userData = JSON.parse(userData);
let user = { username: "admin1", password: "12345" };
let tag = false;
for (let key of userData) {
    if (key.username == user.username) {
        tag = true;
        break;
    }
}
if (!tag) {
    userData.push(user);
    userData = JSON.stringify(userData);
    fs.writeFileSync(__dirname + '/persons.json', userData);
    console.log('注册成功')
}
else {
    console.log('该用户已注册');
}
